﻿using Devonline.AspNetCore;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Logging;

namespace Devonline.Identity;

/// <summary>
/// 字符串作为主键的主数据的附加信息类服务
/// 一个业务数据中仅有一个类型为: TAdditional 的附加信息集合
/// </summary>
/// <typeparam name="TAdditional">附加信息数据类型</typeparam>
public interface IDataAdditionalService<TEntitySet, TAdditional> :
    IDataAdditionalService<IdentityDbContext, TEntitySet, TAdditional>
    where TEntitySet : class, IEntitySet
    where TAdditional : class, IAdditional
{ }

/// <summary>
/// 业务数据带附加信息类服务
/// 字符串作为主键的主数据的附加信息类服务
/// 一个业务数据中仅有一个类型为: TAdditional 的附加信息集合
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
/// <typeparam name="TAdditional">附加信息数据类型</typeparam>
public interface IDataWithAdditionalService<TEntitySet, TAdditional> :
    IDataWithAdditionalService<IdentityDbContext, TEntitySet, TAdditional>,
    IDataService<TEntitySet>,
    IDataAdditionalService<TEntitySet, TAdditional>
    where TEntitySet : class, IEntitySet
    where TAdditional : class, IAdditional
{ }

/// <summary>
/// 字符串作为主键的附加信息类服务
/// 每个 TEntitySet 类型中的 TAdditional 类型的附加信息认为有且仅有一个
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
/// <typeparam name="TAdditional">附加信息数据类型</typeparam>
public class DataWithAdditionalService<TEntitySet, TAdditional> :
    DataWithAdditionalService<IdentityDbContext, TEntitySet, TAdditional>,
    IDataService<TEntitySet>,
    IDataWithAdditionalService<TEntitySet, TAdditional>,
    IDataAdditionalService<TEntitySet, TAdditional>
    where TEntitySet : class, IEntitySet
    where TAdditional : class, IAdditional
{
    public DataWithAdditionalService(
        IdentityDbContext context,
        ILogger<DataWithAdditionalService<TEntitySet, TAdditional>> logger,
        IDistributedCache cache,
        IHttpContextAccessor httpContextAccessor,
        AppSetting appSetting
        ) : base(context, logger, cache, httpContextAccessor, appSetting) { }
}